-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use WASM's saturating casts if they are available #73724
Conversation
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Could a test be added for this as well? Ideally we'd have both a codegen test and a functionality-based test. For a functionality-based test you could add something to src/test/ui
with // only-wasm
(I think) which has a // compile-flags: -Ctarget-feature=+nontrapping-fptoint
directive. For a codegen test you'd have to explore the src/test/codegen
directory a bit, I'm not sure how that works for codegen tests that only apply to one architecture. I can help out though if issues arise!
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
I added the codegen test. Not sure what UI test I should create here. Seems like UI tests are mostly about checking for compiler errors and such, but there's not really any. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! FWIW the "ui" in the test suite was an older name, nowadays basically every test lives in src/test/ui
. You can use // run-pass
(IIRC) to have the test actually run.
@bors: r+ Thanks so much for this! |
📌 Commit 0e8a69a has been approved by |
…crichton Use WASM's saturating casts if they are available WebAssembly supports saturating floating point to integer casts behind a target feature. The feature is already available on many browsers. Beginning with 1.45 Rust will start defining the behavior of floating point to integer casts to be saturating as well. For this Rust constructs additional checks on top of the `fptoui` / `fptosi` instructions it emits. Here we introduce the possibility for the codegen backend to construct saturating casts itself and only fall back to constructing the checks ourselves if that is not possible. Resolves part of rust-lang#73591
…crichton Use WASM's saturating casts if they are available WebAssembly supports saturating floating point to integer casts behind a target feature. The feature is already available on many browsers. Beginning with 1.45 Rust will start defining the behavior of floating point to integer casts to be saturating as well. For this Rust constructs additional checks on top of the `fptoui` / `fptosi` instructions it emits. Here we introduce the possibility for the codegen backend to construct saturating casts itself and only fall back to constructing the checks ourselves if that is not possible. Resolves part of rust-lang#73591
WebAssembly supports saturating floating point to integer casts behind a target feature. The feature is already available on many browsers. Beginning with 1.45 Rust will start defining the behavior of floating point to integer casts to be saturating as well. For this Rust constructs additional checks on top of the `fptoui` / `fptosi` instructions it emits. Here we introduce the possibility for the codegen backend to construct saturating casts itself and only fall back to constructing the checks ourselves if that is not possible.
0e8a69a
to
838c497
Compare
I rebased the commits onto the latest master. |
@bors: r+ |
📌 Commit 838c497 has been approved by |
…crichton Use WASM's saturating casts if they are available WebAssembly supports saturating floating point to integer casts behind a target feature. The feature is already available on many browsers. Beginning with 1.45 Rust will start defining the behavior of floating point to integer casts to be saturating as well. For this Rust constructs additional checks on top of the `fptoui` / `fptosi` instructions it emits. Here we introduce the possibility for the codegen backend to construct saturating casts itself and only fall back to constructing the checks ourselves if that is not possible. Resolves part of rust-lang#73591
…arth Rollup of 8 pull requests Successful merges: - rust-lang#73454 (Move contributing.md to rustc-dev-guide and point at getting started) - rust-lang#73724 (Use WASM's saturating casts if they are available) - rust-lang#73726 (resolve: disallow labelled breaks/continues through closures/async blocks) - rust-lang#73753 (Use 'tcx for references to AccessLevels wherever possible.) - rust-lang#73781 (Update psm version) - rust-lang#73952 (Add option for local docker testing.) - rust-lang#73957 (disable BTree min_max test in Miri for now) - rust-lang#73975 (Document rustc_ast::ast::Pat) Failed merges: r? @ghost
WebAssembly supports saturating floating point to integer casts behind a target feature. The feature is already available on many browsers. Beginning with 1.45 Rust will start defining the behavior of floating point to integer casts to be saturating as well. For this Rust constructs additional checks on top of the
fptoui
/fptosi
instructions it emits. Here we introduce the possibility for the codegen backend to construct saturating casts itself and only fall back to constructing the checks ourselves if that is not possible.Resolves part of #73591